package com.buddy.qreport.template.tpls.line.basic;

import com.buddy.qreport.template.IReportTemplate;
import com.buddy.qreport.template.ReportDataDimension;
import com.buddy.qreport.template.annotation.ReportTemplate;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

@ReportTemplate(type = IReportTemplate.TYPE_NAME_LINE)
public class BasicLineReportTemplate implements IReportTemplate {

    private List<ReportDataDimension> reportDataDimensions;

    private final String demoJs;

    private final String optionJs;

    public BasicLineReportTemplate(){

        demoJs =  new BufferedReader(new InputStreamReader(getClass().getClassLoader().getResourceAsStream("template/line/basic/demo.js")))
                .lines().parallel().collect(Collectors.joining("\n"));


        optionJs =  new BufferedReader(new InputStreamReader(getClass().getClassLoader().getResourceAsStream("template/line/basic/template.js")))
                .lines().parallel().collect(Collectors.joining("\n"));


        reportDataDimensions = new ArrayList<>();

        reportDataDimensions.add(new ReportDataDimension("数据","data",true));
        reportDataDimensions.add(new ReportDataDimension("X轴","x",false));

    }



    @Override
    public String getName() {
        return "basic_line";
    }

    @Override
    public String getDescription() {
        return "基础折线图";
    }

    @Override
    public String getTemplateOptionJs() {
        return optionJs;
    }

    @Override
    public String getDemoJs() {
        return demoJs;
    }

    @Override
    public List<ReportDataDimension> getDataDimensions() {
        return reportDataDimensions;
    }
}
